<html> 
<head>
  <style>
    .ok {
      color: green;
    }
    .error {
      color: red;
      font-weight: bold;
    }
  </style>
</head>

<body>

<script>
  var FLAG_IN_TEST = true;

  var chrome = chrome || {};;
  chrome.extension = chrome.extension || {};
  chrome.extension.onRequest = chrome.extension.onRequest || {};
  chrome.extension.onRequest.addListener = function() {};
</script>
<script src="../src/content/main.js"></script>

<!-- Setup tests framework -->
<script>
  var lastDocumentWriteResult = '';
  var origWrite = document.write;

  (function() {
    document.write = function(str) {
      lastDocumentWriteResult = str;
    };
    document.writeln = function(str) {
      document.write(str + '\n');
    };
    ContentFilter.EMBED_FUNC_(window, document);
  })();

  function outputResult(name, isPassed) {
    if (isPassed) {
      origWrite.call(document, '<div class="ok">Test ' + name + ': PASSED</div>');
    } else {
      origWrite.call(document, '<div class="error">Test ' + name + ': FAILED!</div>');
      console.log('Test ' + name + ': lastDocumentWriteResult = ' + lastDocumentWriteResult);
    }
  }

  function doTestExpectRemoved(name, content) {
    lastDocumentWriteResult = '';
    document.write(content);
    outputResult(name, !lastDocumentWriteResult);
  }

  function doTestExpectPreserved(name, content) {
    lastDocumentWriteResult = '';
    document.write(content);
    outputResult(name, lastDocumentWriteResult === content);
  }

  function doTestAndExpect(name, content, expected) {
    lastDocumentWriteResult = '';
    document.write(content);
    outputResult(name, lastDocumentWriteResult === expected);
  }

</script>


<script>
  /*
   * Preserved
   */
  doTestExpectPreserved('Recaptcha',
    '<scr'+'ipt type="text/javascript" s'+'rc="http://api.recaptcha.net/js/recaptcha.js"></scr'+'ipt>'
  );
  doTestExpectPreserved('Maps',
    '<scr'+'ipt s'+'rc="http://maps.gstatic.com/intl/en_ALL/mapfiles/240c/maps2.api/main.js" type="text/javascript" >  </scr'+'ipt> '
  );
  doTestExpectPreserved('MapsUnclosed',
    '<scr'+'ipt s'+'rc="http://maps.gstatic.com/intl/en_ALL/mapfiles/240c/maps2.api/main.js" type="text/javascript">'
  );
  doTestExpectPreserved('VisualizationApi',
    '<scr'+'ipt src="http://www.google.com/uds/api/visualization/1.0/e9f5bea2f5fcf88c5d872773ba55a57c/default,geomap.I.js" type="text/javascript"></scr'+'ipt>'
  );
  doTestExpectPreserved('VisualizationApi2',
    '<scr' + 'ipt src="http://www.google.com/uds/?file=visualization&v=1&packages=geomap" type="text/javascript"></scr' + 'ipt>'
  );

  doTestExpectPreserved('MapsInside',
    '<div>\n<span>\n' +
        '<scr'+'ipt s'+'rc="http://maps.gstatic.com/intl/en_ALL/mapfiles/240c/maps2.api/main.js" type="text/javascript" ></scr'+'ipt>' +
        '</span></div>'
  );
  doTestExpectPreserved('YandexMaps',
    '<div>\n<span>\n' +
        '<scr'+'ipt s'+'rc="http://api-maps.yandex.ru/file.js" type="text/javascript" ></scr'+'ipt>' +
        '</span></div>'
  );
  doTestExpectPreserved('CustomStyles',
    '<style type="text/css"> a.mctitle:link,a.mctitle:active,a.mctitle:visited{ font-size: 12px; font-weight:normal; font-family :arial; color:#2862a8;text-decoration:none; }a.mctitle:hover{text-decoration:underline;} a.mcdesc:link,a.mcdesc:active,a.mcdesc:hover,a.mcdesc:visited{ font-size:11px; font-weight: normal; color:#000; text-decoration: none; font-family:tahoma; } .mctable td{ padding:0px; } .mctable img{ border: 1px solid #cccccc; margin: 5px 5px 2px 0px; } </style>'
  );
  doTestExpectPreserved('CustomHtml',
    '<input type="text" name="history_state0" id="history_state0" style="display:none" />'
  );
//  doTestExpectPreserved('YouTubeObject',
//    '<object height="385" width="640" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="movie_player" ><param name="movie" value="http://s.ytimg.com/yt/swf/watch_as3-vfl165673.swf"></object>'
//  );
  doTestExpectPreserved('YouTubeEmbed',
    '<embed height="385" width="640" type="application/x-shockwave-flash" src="http://s.ytimg.com/yt/swf/watch_as3-vfl165673.swf" >'
  );
  doTestExpectPreserved('RelativeLinks1',
    '<embed height="385" width="640" type="application/x-shockwave-flash" src="swf/watch_as3-vfl165673.swf" >'
  );
  doTestExpectPreserved('RelativeLinks2',
    '<scr'+'ipt charset="windows-1251" s'+'rc="/net/j/2518/1" type="text/javascript" ></scr'+'ipt>'
  );

  
  /*
   * Removed
   */
  doTestExpectRemoved('RemoveAds',
    '<scr'+'ipt charset="windows-1251" s'+'rc="http://ac.goodsblock.dt00.net/j/2518/1" type="text/javascript" ></scr'+'ipt>'
  );
  doTestExpectRemoved('RemoveGoogleAnalytics',
    '<scr'+'ipt s'+'rc="http://www.google-analytics.com/ga.js" type="text/javascript" ></scr'+'ipt>'
  );

  /*
   * Customized tests
   */
  doTestAndExpect('ScriptClosed',
    '</scr'+'ipt>',
    '</scr'+'ipt> <'+'!-- --'+'>');

  doTestAndExpect('IframeAdsMultipleDocWrites1',
    '<iframe src="http://ads.livetv.ru/getbanner.php">',
    '<'+'!-- iframe src="http://ads.livetv.ru/getbanner.php">'
  );
  doTestAndExpect('IframeAdsMultipleDocWrites2',
    '</iframe>',
    '</iframe> <'+'!-- --'+'>'
  );

</script>


<!--

<script charset="windows-1251" type="text/javascript" src="http://ac.goodsblock.dt00.net/j/2518/1"></script>

<a href="http://www.liveinternet.ru/click" target=_blank><img src="http://counter.yadro.ru/hit?t45.6;r;s1280*1024*32;uhttp%3A//tfile.ru/;0.28401979780755937" border=0 width=31 height=31 alt="" title="LiveInternet"></a>

<iframe src="http://gazeta.adfox.ru/getCode?pp=h&amp;ps=dq&amp;p2=bn&amp;p3=1&amp;p4=a&amp;pr=6729966&amp;pt=on&amp;pd=23&amp;pw=0&amp;pv=13&amp;pq=b&amp;pn=b&amp;py=a" frameBorder="0" width="234" height="120" marginWidth="0" marginHeight="0" scrolling="no" style="border: 0px; margin: 0px; padding: 0px;"><a href="http://gazeta.adfox.ru/goDefaultLink?pp=h&amp;ps=dq&amp;p2=bn&amp;py=a" target="_blank"><img src="http://gazeta.adfox.ru/getDefaultImage?pp=h&amp;ps=dq&amp;p2=bn" border="0" alt=""></a></iframe>

<div id="sup_ad_3436259629_place" style="width: 1px; height: 1px"><iframe name="sup_ad" id="sup_ad_3436259629" width="1px;" height="1px" frameborder="no" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" style="padding: 0; margin: 0; display: block; z-index: 0"></iframe></div>

<script src='http://www.google-analytics.com/ga.js' type='text/javascript'></script>

------------
<style type="text/css"> a.mctitle:link,a.mctitle:active,a.mctitle:visited{ font-size: 12px; font-weight:normal; font-family :arial; color:#2862a8;text-decoration:none; }a.mctitle:hover{text-decoration:underline;} a.mcdesc:link,a.mcdesc:active,a.mcdesc:hover,a.mcdesc:visited{ font-size:11px; font-weight: normal; color:#000; text-decoration: none; font-family:tahoma; } .mctable td{ padding:0px; } .mctable img{ border: 1px solid #cccccc; margin: 5px 5px 2px 0px; } </style>

<input type="text" name="history_state0" id="history_state0" style="display:none" />

<script src="http://maps.gstatic.com/intl/en_ALL/mapfiles/240c/maps2.api/main.js" type="text/javascript"></script>

-->

</body>
</html>
